<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>深度克隆</title>
</head>
<body>
<script type="text/javascript">
function deepClone(obj) {
	let result = obj;
	if(obj == null) {
		return obj;
	}else if(obj instanceof Date) {
		return new Date(obj);
	}else if(obj instanceof RegExp) {
		return new RegExp(obj);
	}else if(typeof obj == 'object') {
		result = Object.prototype.toString.call(obj) == '[object Array]' ? []:{};
		for(let key in obj) {
			result[key] = deepClone(obj[key]);
		}
	}

	return result;
}

	// 深拷贝
let obj1 = {
    name : '浪里行舟',
    arr : [1,[2,3],4],
    date: (new Date()),
};
let obj2 = deepClone(obj1)
</script>
</body>
</html>